package cn.wolfcode.wolf2w.web.controller;

import cn.wolfcode.wolf2w.util.UploadUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.Optional;

@Controller
public class UploadImgController {
    @RequestMapping("coverImageUpload")
    @ResponseBody
    public Object coverImageUpload(MultipartFile pic) {
        //将pic数据存到项目文件中
        //通过oss提供api将图片数据上传到阿里云的OSS服务器中(我自己的buket)
        String url = null;
//        System.out.println(multipartFile.getName());
        try {
            url = UploadUtil.uploadAli(pic);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return url;
    }
}
